Adapter shim for pollable incompatibility#600
Open
cceckman-at-fastly wants to merge 6 commits intomainfrom
Open
Adapter shim for pollable incompatibility#600cceckman-at-fastly wants to merge 6 commits intomainfrom
cceckman-at-fastly wants to merge 6 commits intomainfrom
Conversation
These resources are pollable (`async_io::select`-able) in the WITX ABI, but are not `async-io.pollable` in the WIT ABI. To allow the adapter to shim the differences, add `subscribe` calls to the WIT definitions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There are many handle types that, in WITX, are valid for
async_io::select; among them are cache handles, cache replace handles, and HTTP cache handles. Each of these is backed with an async item (well, not HTTP cache handles, because they are not yet implemented in Viceroy) and can be waited on byselect. The module ABI doesn't have strong notions of typing; these u32s are all in the same space.In WIT, everything that can be waited on by
async-io.selectis an alias for theasync-io.pollablehandle type. The "component" version of Wasmtime checks these handles by type; not all u32s are the same.But
cache-entry,cache-replace-entry, andhttp-cache-entryare not such aliases; they are their own resources. If you pass one of these handles toasync-io.select, you'll get an error.We realized this leads to an incompatibility in adapted code. Code that works as a module (passing e.g.
cache-entrytoselect) will break under the adapter, prior to this change.This adds a shim layer to the adapter, tagging the three handle types above with extra bits in the high nybble. (These bits are reserved for purposes like this.) The adapter sets these bits per-type when producing the handle, and removes them before calling down in to the component ABI.
When these incompatible handles arrive at
select(oris_ready), the adapter strips the type bits out to recover the handle, then uses it to callsubscribe.subscribereturns the same handle, but tracked as apollable, so it can then be fed in to the underlying ABI call.